package com.qf.controller;

import com.qf.dto.ResultBean;
import com.qf.service.impl.ICartServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author NingZhongYi
 * @Date 2020-03-11
 */
@Controller
public class CartController {

    @Autowired
    private ICartServiceImpl cartService;


    // 添加购物车
    @RequestMapping("addCart/{productId}/{count}")
    @ResponseBody
    public ResultBean addCart(String uuid,@PathVariable Long productId, @PathVariable Integer count){
        return cartService.addProductToCart(uuid,productId,count);
    }

    // 删除购物车
    @RequestMapping("cleanCart/{uuid}")
    @ResponseBody
    public ResultBean cleanCart(@PathVariable String uuid){
        return cartService.cleanCart(uuid);
    }

    // 查看购物车
    @RequestMapping("showCart/{uuid}")
    @ResponseBody
    public ResultBean showCart(@PathVariable String uuid){
        return cartService.showCart(uuid);
    }

}
